package main;

import main.app.EchoApp;
import main.app.ChatApp;
import main.server.NioTcpServer;


public class Manager {

	public static void main(String[] args) {
		if (args[0].equals("start-echo-server")) {
			startEchoServer();
		}
		else if (args[0].equals("start-chat-server")) {
			startChatServer();
		}
	}

	public static void startEchoServer() {
		try {
			NioTcpServer server = new NioTcpServer(5000);
			EchoApp app = new EchoApp();
			Thread thread = new Thread(server);

			app.setServer(server);
			server.setAppClass(app.getClass());

			thread.start();
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static void startChatServer() {
		try {
			NioTcpServer server = new NioTcpServer(5000);
			ChatApp app = new ChatApp();
			Thread thread = new Thread(server);

			app.setServer(server);
			server.setAppClass(app.getClass());

			thread.start();
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
